home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1996 May: Tool Chest / Developer CD Series May 1996 (Tool Chest) (Apple Computer) (1996).iso / Tool Chest / Development Tools & Languages / Macintosh Common Lisp Related / think-c-interface.sea / Think C interface / example.lisp < prev    next >
MacBinary  |  1991-12-05  |  5.3 KB  |  [TEXT/CCL2]

open in: MacOS 8.1     |     Win98     |     DOS

browse contents    |     view JSON data     |     view as text


This file was processed as: MacBinary (archive/macBinary).

ConfidenceProgramDetectionMatch TypeSupport
10% dexvert MacBinary (archive/macBinary) fallback Supported
1% dexvert Text File (text/txt) fallback Supported
100% file MacBinary II, inited, Thu Dec 5 10:28:07 1991, modified Thu Dec 5 10:28:07 1991, creator Common Lisp 2, type ASCII, 4619 bytes "example.lisp" , at 0x128b 444 bytes resource default (weak)
99% file data default
74% TrID Macintosh plain text (MacBinary) default
25% TrID MacBinary 2 default (weak)
100% siegfried fmt/1762 MacBinary (II) default
100% lsar MacBinary default


id metadata
keyvalue
macFileType[TEXT]
macFileCreator[CCL2]



hex view
+--------+-------------------------+-------------------------+--------+--------+
|00000000| 00 0c 65 78 61 6d 70 6c | 65 2e 6c 69 73 70 00 00 |..exampl|e.lisp..|
|00000010| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|00000020| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|00000030| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|00000040| 00 54 45 58 54 43 43 4c | 32 01 00 00 00 00 00 00 |.TEXTCCL|2.......|
|00000050| 00 00 00 00 00 12 0b 00 | 00 01 bc a5 63 f6 07 a5 |........|....c...|
|00000060| 63 f6 07 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |c.......|........|
|00000070| 00 00 00 00 00 00 00 00 | 00 00 81 81 87 dc 00 00 |........|........|
|00000080| 3b 3b 3b 20 2d 2a 2d 20 | 70 61 63 6b 61 67 65 3a |;;; -*- |package:|
|00000090| 20 43 4c 2d 55 53 45 52 | 20 2d 2a 2d 0d 3b 3b 3b | CL-USER| -*-.;;;|
|000000a0| 0d 3b 3b 3b 20 20 45 78 | 61 6d 70 6c 65 20 66 6f |.;;; Ex|ample fo|
|000000b0| 72 20 74 68 65 20 4d 43 | 4c 20 3c 2d 3e 20 54 68 |r the MC|L <-> Th|
|000000c0| 69 6e 6b 43 20 69 6e 74 | 65 72 66 61 63 65 0d 3b |inkC int|erface.;|
|000000d0| 3b 3b 0d 0d 0d 28 69 6e | 2d 70 61 63 6b 61 67 65 |;;...(in|-package|
|000000e0| 20 22 43 4c 2d 55 53 45 | 52 22 29 0d 28 75 73 65 | "CL-USE|R").(use|
|000000f0| 2d 70 61 63 6b 61 67 65 | 20 22 54 48 49 4e 4b 2d |-package| "THINK-|
|00000100| 43 22 29 0d 0d 0d 28 64 | 65 66 76 61 72 20 2a 72 |C")...(d|efvar *r|
|00000110| 65 73 6f 75 72 63 65 2d | 66 69 6c 65 2a 0d 20 20 |esource-|file*. |
|00000120| 6e 69 6c 29 0d 0d 0d 28 | 64 65 66 63 6d 6f 64 75 |nil)...(|defcmodu|
|00000130| 6c 65 20 65 78 61 6d 70 | 6c 65 0d 20 20 3b 3b 0d |le examp|le. ;;.|
|00000140| 20 20 3b 3b 20 49 66 20 | 79 6f 75 20 64 6f 20 6e | ;; If |you do n|
|00000150| 6f 74 20 73 70 65 63 69 | 66 79 20 61 20 72 65 73 |ot speci|fy a res|
|00000160| 6f 75 72 63 65 20 66 69 | 6c 65 2c 20 69 74 20 64 |ource fi|le, it d|
|00000170| 65 66 61 75 6c 74 73 20 | 74 6f 0d 20 20 3b 3b 20 |efaults |to. ;; |
|00000180| 28 6d 65 72 67 65 2d 70 | 61 74 68 6e 61 6d 65 73 |(merge-p|athnames|
|00000190| 20 2a 54 48 49 4e 4b 2d | 43 2d 46 4f 4c 44 45 52 | *THINK-|C-FOLDER|
|000001a0| 2a 20 28 73 79 6d 62 6f | 6c 2d 6e 61 6d 65 20 6d |* (symbo|l-name m|
|000001b0| 6f 64 75 6c 65 2d 6e 61 | 6d 65 29 29 2e 0d 20 20 |odule-na|me)).. |
|000001c0| 3b 3b 0d 20 20 3a 72 65 | 73 6f 75 72 63 65 2d 66 |;;. :re|source-f|
|000001d0| 69 6c 65 0d 20 20 28 6f | 72 20 2a 72 65 73 6f 75 |ile. (o|r *resou|
|000001e0| 72 63 65 2d 66 69 6c 65 | 2a 0d 20 20 20 20 20 20 |rce-file|*. |
|000001f0| 28 73 65 74 71 20 2a 72 | 65 73 6f 75 72 63 65 2d |(setq *r|esource-|
|00000200| 66 69 6c 65 2a 0d 20 20 | 20 20 20 20 20 20 20 20 |file*. | |
|00000210| 20 20 28 70 72 6f 67 6e | 0d 20 20 20 20 20 20 20 | (progn|. |
|00000220| 20 20 20 20 20 20 20 28 | 6d 65 73 73 61 67 65 2d | (|message-|
|00000230| 64 69 61 6c 6f 67 20 22 | 50 6c 65 61 73 65 20 73 |dialog "|Please s|
|00000240| 65 6c 65 63 74 20 74 68 | 65 20 27 65 78 61 6d 70 |elect th|e 'examp|
|00000250| 6c 65 2e 72 65 73 27 20 | 66 69 6c 65 2e 22 29 0d |le.res' |file.").|
|00000260| 20 20 20 20 20 20 20 20 | 20 20 20 20 20 20 28 63 | | (c|
|00000270| 68 6f 6f 73 65 2d 66 69 | 6c 65 2d 64 69 61 6c 6f |hoose-fi|le-dialo|
|00000280| 67 29 29 29 29 0d 20 20 | 3a 76 61 72 69 61 62 6c |g)))). |:variabl|
|00000290| 65 73 0d 20 20 28 6d 79 | 2d 6c 6f 6e 67 0d 20 20 |es. (my|-long. |
|000002a0| 20 6d 79 2d 64 6f 75 62 | 6c 65 29 0d 20 20 3a 66 | my-doub|le). :f|
|000002b0| 75 6e 63 74 69 6f 6e 73 | 0d 20 20 28 28 74 65 73 |unctions|. ((tes|
|000002c0| 74 2d 66 69 78 6e 75 6d | 20 20 20 20 20 20 20 20 |t-fixnum| |
|000002d0| 28 3a 6c 69 73 70 29 20 | 20 3a 64 30 29 0d 20 20 |(:lisp) | :d0). |
|000002e0| 20 28 74 65 73 74 2d 63 | 68 61 72 61 63 74 65 72 | (test-c|haracter|
|000002f0| 20 20 20 20 20 28 3a 6c | 69 73 70 29 20 20 3a 64 | (:l|isp) :d|
|00000300| 30 29 0d 20 20 20 3b 3b | 0d 20 20 20 3b 3b 20 49 |0). ;;|. ;; I|
|00000310| 66 20 79 6f 75 20 77 61 | 6e 74 20 79 6f 75 72 20 |f you wa|nt your |
|00000320| 61 72 67 75 6d 65 6e 74 | 73 20 74 6f 20 68 61 76 |argument|s to hav|
|00000330| 65 20 6d 6f 72 65 20 6d | 65 61 6e 69 6e 67 66 75 |e more m|eaningfu|
|00000340| 6c 6c 20 6e 61 6d 65 73 | 0d 20 20 20 3b 3b 20 79 |ll names|. ;; y|
|00000350| 6f 75 20 63 61 6e 20 75 | 73 65 20 74 68 69 73 20 |ou can u|se this |
|00000360| 61 6c 74 65 72 6e 61 74 | 65 20 73 79 6e 74 61 78 |alternat|e syntax|
|00000370| 20 66 6f 72 20 74 68 65 | 20 61 72 67 75 6d 65 6e | for the| argumen|
|00000380| 74 73 2e 0d 20 20 20 3b | 3b 0d 20 20 20 28 74 65 |ts.. ;|;. (te|
|00000390| 73 74 2d 6c 69 73 74 20 | 20 20 20 20 20 20 20 20 |st-list | |
|000003a0| 20 28 28 6c 69 73 74 20 | 3a 6c 69 73 70 29 29 20 | ((list |:lisp)) |
|000003b0| 3a 6e 6f 76 61 6c 75 65 | 29 0d 20 20 20 28 74 65 |:novalue|). (te|
|000003c0| 73 74 2d 73 74 72 75 63 | 74 20 20 20 20 20 20 20 |st-struc|t |
|000003d0| 20 28 3a 6c 69 73 70 29 | 20 20 3a 6e 6f 76 61 6c | (:lisp)| :noval|
|000003e0| 75 65 29 0d 20 20 20 28 | 74 65 73 74 2d 76 65 63 |ue). (|test-vec|
|000003f0| 74 6f 72 20 20 20 20 20 | 20 20 20 28 3a 6c 69 73 |tor | (:lis|
|00000400| 70 29 20 20 3a 6e 6f 76 | 61 6c 75 65 29 0d 20 20 |p) :nov|alue). |
|00000410| 20 28 74 65 73 74 2d 73 | 74 72 69 6e 67 20 20 20 | (test-s|tring |
|00000420| 20 20 20 20 20 28 3a 6c | 69 73 70 29 20 20 3a 6e | (:l|isp) :n|
|00000430| 6f 76 61 6c 75 65 29 0d | 20 20 20 3b 3b 0d 20 20 |ovalue).| ;;. |
|00000440| 20 3b 3b 20 54 68 65 20 | 54 68 69 6e 6b 43 20 74 | ;; The |ThinkC t|
|00000450| 79 70 65 20 74 68 61 74 | 20 63 6f 72 72 65 73 70 |ype that| corresp|
|00000460| 6f 6e 64 73 20 74 6f 20 | 4d 43 4c 27 73 20 66 6c |onds to |MCL's fl|
|00000470| 6f 61 74 69 6e 67 20 70 | 6f 69 6e 74 0d 20 20 20 |oating p|oint. |
|00000480| 3b 3b 20 69 73 20 73 68 | 6f 72 74 20 64 6f 75 62 |;; is sh|ort doub|
|00000490| 6c 65 2e 20 49 20 70 72 | 6f 76 69 64 65 64 20 61 |le. I pr|ovided a|
|000004a0| 20 77 61 79 20 74 6f 20 | 70 61 73 73 20 54 68 69 | way to |pass Thi|
|000004b0| 6e 6b 43 20 64 6f 75 62 | 6c 65 73 0d 20 20 20 3b |nkC doub|les. ;|
|000004c0| 3b 20 62 65 74 77 65 65 | 6e 20 43 20 61 6e 64 20 |; betwee|n C and |
|000004d0| 4d 43 4c 20 62 65 63 61 | 75 73 65 20 74 68 69 73 |MCL beca|use this|
|000004e0| 20 69 73 20 74 68 65 20 | 74 79 70 65 20 6f 66 20 | is the |type of |
|000004f0| 74 68 65 20 36 38 38 38 | 2a 2e 0d 20 20 20 3b 3b |the 6888|*.. ;;|
|00000500| 20 53 6f 20 69 66 20 79 | 6f 75 20 62 61 64 6c 79 | So if y|ou badly|
|00000510| 20 6e 65 65 64 20 65 66 | 66 69 63 69 65 6e 63 79 | need ef|ficiency|
|00000520| 20 79 6f 75 20 63 61 6e | 20 75 73 65 20 74 68 69 | you can| use thi|
|00000530| 73 2e 0d 20 20 20 3b 3b | 0d 20 20 20 28 74 65 73 |s.. ;;|. (tes|
|00000540| 74 2d 73 68 6f 72 74 2d | 64 6f 75 62 6c 65 20 20 |t-short-|double |
|00000550| 28 3a 6c 69 73 70 29 20 | 20 3a 6e 6f 76 61 6c 75 |(:lisp) | :novalu|
|00000560| 65 29 0d 20 20 20 28 74 | 65 73 74 2d 64 6f 75 62 |e). (t|est-doub|
|00000570| 6c 65 20 20 20 20 20 20 | 20 20 28 3a 6d 61 63 29 |le | (:mac)|
|00000580| 20 20 20 3a 6e 6f 76 61 | 6c 75 65 29 0d 20 20 20 | :nova|lue). |
|00000590| 28 74 65 73 74 2d 63 2d | 73 74 72 75 63 74 75 72 |(test-c-|structur|
|000005a0| 65 73 20 20 28 3a 6d 61 | 63 29 20 20 20 3a 6e 6f |es (:ma|c) :no|
|000005b0| 76 61 6c 75 65 29 0d 20 | 20 20 28 74 65 73 74 2d |value). | (test-|
|000005c0| 61 30 20 20 20 20 20 20 | 20 20 20 20 20 20 28 3a |a0 | (:|
|000005d0| 6d 61 63 29 20 20 20 3a | 61 30 29 0d 20 20 20 3b |mac) :|a0). ;|
|000005e0| 3b 0d 20 20 20 3b 3b 20 | 49 66 20 79 6f 75 20 77 |;. ;; |If you w|
|000005f0| 61 6e 74 20 54 68 69 6e | 6b 43 20 74 6f 20 6d 61 |ant Thin|kC to ma|
|00000600| 6b 65 20 63 61 6c 6c 20 | 62 61 63 6b 73 20 74 6f |ke call |backs to|
|00000610| 20 4c 69 73 70 20 79 6f | 75 20 68 61 76 65 20 74 | Lisp yo|u have t|
|00000620| 6f 20 62 65 0d 20 20 20 | 3b 3b 20 63 61 72 65 66 |o be. |;; caref|
|00000630| 75 6c 6c 20 62 65 63 61 | 75 73 65 20 61 20 63 61 |ull beca|use a ca|
|00000640| 6c 6c 62 61 63 6b 20 63 | 61 6e 20 67 69 76 65 20 |llback c|an give |
|00000650| 72 69 73 65 20 74 6f 20 | 61 20 47 43 20 77 68 69 |rise to |a GC whi|
|00000660| 63 68 20 63 61 6e 0d 20 | 20 20 3b 3b 20 69 6e 76 |ch can. | ;; inv|
|00000670| 61 6c 69 64 61 74 65 20 | 74 68 65 20 70 6f 69 6e |alidate |the poin|
|00000680| 74 65 72 73 20 74 68 61 | 74 20 43 20 68 61 73 20 |ters tha|t C has |
|00000690| 69 6e 20 74 68 65 20 4c | 69 73 70 20 77 6f 72 6c |in the L|isp worl|
|000006a0| 64 2e 0d 20 20 20 3b 3b | 20 47 61 72 79 20 42 79 |d.. ;;| Gary By|
|000006b0| 65 72 73 20 70 6f 69 6e | 74 65 64 20 6f 75 74 20 |ers poin|ted out |
|000006c0| 74 6f 20 6d 65 20 74 68 | 61 74 20 65 76 65 6e 20 |to me th|at even |
|000006d0| 69 66 20 79 6f 75 20 64 | 6f 6e 74 20 6d 61 6b 65 |if you d|ont make|
|000006e0| 20 61 6e 79 0d 20 20 20 | 3b 3b 20 63 61 6c 6c 20 | any. |;; call |
|000006f0| 62 61 63 6b 73 20 74 6f | 20 4c 69 73 70 2c 20 61 |backs to| Lisp, a|
|00000700| 20 72 65 71 75 65 73 74 | 20 74 6f 20 74 68 65 20 | request| to the |
|00000710| 6d 61 63 69 6e 74 6f 73 | 68 20 6d 65 6d 6f 72 79 |macintos|h memory|
|00000720| 20 6d 61 6e 61 67 65 72 | 0d 20 20 20 3b 3b 20 63 | manager|. ;; c|
|00000730| 61 6e 20 70 6f 73 73 69 | 62 6c 79 20 72 65 73 75 |an possi|bly resu|
|00000740| 6c 74 20 69 6e 20 74 72 | 69 67 67 65 72 69 6e 67 |lt in tr|iggering|
|00000750| 20 61 20 4d 43 4c 20 67 | 61 72 62 61 67 65 20 63 | a MCL g|arbage c|
|00000760| 6f 6c 6c 65 63 74 21 0d | 20 20 20 3b 3b 0d 20 20 |ollect!.| ;;. |
|00000770| 20 3b 3b 20 59 6f 75 72 | 20 43 20 63 6f 64 65 20 | ;; Your| C code |
|00000780| 63 61 6e 20 6d 61 6b 65 | 20 63 61 6c 6c 62 61 63 |can make| callbac|
|00000790| 6b 73 20 74 6f 20 4c 69 | 73 70 20 62 65 63 61 75 |ks to Li|sp becau|
|000007a0| 73 65 20 69 74 20 6f 6e | 6c 79 20 67 65 74 73 0d |se it on|ly gets.|
|000007b0| 20 20 20 3b 3b 20 70 6f | 69 6e 74 65 72 73 20 74 | ;; po|inters t|
|000007c0| 6f 20 74 68 65 20 61 63 | 74 75 61 6c 20 61 72 67 |o the ac|tual arg|
|000007d0| 75 6d 65 6e 74 73 2c 20 | 74 68 6f 73 65 20 70 6f |uments, |those po|
|000007e0| 69 6e 74 65 72 73 20 62 | 65 69 6e 67 20 75 70 64 |inters b|eing upd|
|000007f0| 61 74 65 64 0d 20 20 20 | 3b 3b 20 61 75 74 6f 6d |ated. |;; autom|
|00000800| 61 74 69 63 61 6c 6c 79 | 20 69 6e 20 63 61 73 65 |atically| in case|
|00000810| 20 6f 66 20 61 20 67 61 | 72 62 61 67 65 20 63 6f | of a ga|rbage co|
|00000820| 6c 6c 65 63 74 69 6f 6e | 2e 0d 20 20 20 3b 3b 0d |llection|.. ;;.|
|00000830| 20 20 20 28 74 65 73 74 | 2d 63 61 6c 6c 62 61 63 | (test|-callbac|
|00000840| 6b 20 20 20 20 20 20 28 | 3a 6c 69 73 70 20 3a 6d |k (|:lisp :m|
|00000850| 61 63 29 20 3a 64 30 29 | 0d 20 20 20 28 74 65 73 |ac) :d0)|. (tes|
|00000860| 74 2d 67 6c 6f 62 61 6c | 73 20 20 20 20 20 20 20 |t-global|s |
|00000870| 28 29 20 3a 64 30 29 0d | 20 20 20 28 74 65 73 74 |() :d0).| (test|
|00000880| 2d 6d 75 6c 74 69 2d 73 | 65 67 6d 65 6e 74 20 28 |-multi-s|egment (|
|00000890| 29 20 3a 64 30 29 0d 20 | 20 20 28 74 65 73 74 2d |) :d0). | (test-|
|000008a0| 74 72 61 70 73 20 20 20 | 20 20 20 20 20 20 28 29 |traps | ()|
|000008b0| 20 3a 61 30 29 29 29 0d | 0d 0d 3b 3b 0d 3b 3b 20 | :a0))).|..;;.;; |
|000008c0| 4c 4f 41 44 2d 43 4d 4f | 44 55 4c 45 20 72 65 61 |LOAD-CMO|DULE rea|
|000008d0| 64 73 20 74 68 65 20 6d | 61 69 6e 20 73 65 67 6d |ds the m|ain segm|
|000008e0| 65 6e 74 20 6f 66 20 79 | 6f 75 72 20 63 6f 64 65 |ent of y|our code|
|000008f0| 20 72 65 73 6f 75 72 63 | 65 20 69 6e 20 6d 65 6d | resourc|e in mem|
|00000900| 6f 72 79 0d 3b 3b 20 61 | 6e 64 20 70 75 74 20 74 |ory.;; a|nd put t|
|00000910| 68 65 20 61 64 64 72 65 | 73 73 20 69 6e 20 74 68 |he addre|ss in th|
|00000920| 65 20 73 79 6d 62 6f 6c | 20 6e 61 6d 69 6e 67 20 |e symbol| naming |
|00000930| 79 6f 75 72 20 43 20 6d | 6f 64 75 6c 65 20 28 68 |your C m|odule (h|
|00000940| 65 72 65 20 45 58 41 4d | 50 4c 45 29 2e 0d 3b 3b |ere EXAM|PLE)..;;|
|00000950| 20 0d 3b 3b 20 4c 4f 41 | 44 2d 43 4d 4f 44 55 4c | .;; LOA|D-CMODUL|
|00000960| 45 20 77 69 6c 6c 20 61 | 6c 73 6f 20 6c 69 6e 6b |E will a|lso link|
|00000970| 20 74 68 65 20 76 61 72 | 69 61 62 6c 65 73 20 61 | the var|iables a|
|00000980| 6e 64 20 66 75 6e 63 74 | 69 6f 6e 73 20 79 6f 75 |nd funct|ions you|
|00000990| 20 64 65 66 69 6e 65 64 | 20 69 6e 0d 3b 3b 20 79 | defined| in.;; y|
|000009a0| 6f 75 72 20 43 20 6d 6f | 64 75 6c 65 20 77 69 74 |our C mo|dule wit|
|000009b0| 68 20 74 68 65 69 72 20 | 63 6f 72 72 65 63 74 20 |h their |correct |
|000009c0| 61 64 64 72 65 73 73 20 | 69 6e 20 6d 65 6d 6f 72 |address |in memor|
|000009d0| 79 2e 20 54 68 65 20 73 | 79 6d 62 6f 6c 20 76 61 |y. The s|ymbol va|
|000009e0| 6c 75 65 20 6f 66 0d 3b | 3b 20 74 68 65 20 76 61 |lue of.;|; the va|
|000009f0| 72 69 61 62 6c 65 73 20 | 77 69 6c 6c 20 63 6f 6e |riables |will con|
|00000a00| 74 61 69 6e 74 20 74 68 | 65 20 61 64 64 72 65 73 |taint th|e addres|
|00000a10| 73 20 6f 66 20 74 68 65 | 69 72 20 43 20 63 6f 75 |s of the|ir C cou|
|00000a20| 6e 74 65 72 70 61 72 74 | 73 20 61 6e 64 20 74 68 |nterpart|s and th|
|00000a30| 65 0d 3b 3b 20 73 79 6d | 62 6f 6c 20 76 61 6c 75 |e.;; sym|bol valu|
|00000a40| 65 20 6f 66 20 74 68 65 | 20 66 75 6e 63 74 69 6f |e of the| functio|
|00000a50| 6e 73 20 77 69 6c 6c 20 | 63 6f 6e 74 61 69 6e 20 |ns will |contain |
|00000a60| 74 68 65 69 72 20 65 6e | 74 72 79 20 70 6f 69 6e |their en|try poin|
|00000a70| 74 20 61 64 64 72 65 73 | 73 2e 0d 3b 3b 0d 3b 3b |t addres|s..;;.;;|
|00000a80| 20 49 74 20 69 73 20 69 | 6d 70 6f 72 74 61 6e 74 | It is i|mportant|
|00000a90| 20 74 6f 20 75 6e 64 65 | 72 73 74 61 6e 64 20 74 | to unde|rstand t|
|00000aa0| 68 61 74 20 4d 43 4c 20 | 64 6f 65 73 6e 74 20 63 |hat MCL |doesnt c|
|00000ab0| 6f 6e 73 65 72 76 65 20 | 74 68 65 20 4d 61 63 20 |onserve |the Mac |
|00000ac0| 68 65 61 70 0d 3b 3b 20 | 61 63 63 72 6f 73 73 20 |heap.;; |accross |
|00000ad0| 61 20 53 41 56 45 2d 41 | 50 50 4c 49 43 41 54 49 |a SAVE-A|PPLICATI|
|00000ae0| 4f 4e 2e 20 54 68 69 73 | 20 69 6d 70 6c 69 65 73 |ON. This| implies|
|00000af0| 20 74 68 61 74 20 69 6e | 20 6f 72 64 65 72 20 66 | that in| order f|
|00000b00| 6f 72 20 79 6f 75 72 20 | 43 20 6d 6f 64 75 6c 65 |or your |C module|
|00000b10| 73 0d 3b 3b 20 74 6f 20 | 62 65 20 72 65 73 74 6f |s.;; to |be resto|
|00000b20| 72 65 64 20 70 72 6f 70 | 65 72 6c 79 2c 20 74 68 |red prop|erly, th|
|00000b30| 65 20 72 65 73 6f 75 72 | 63 65 20 66 69 6c 65 20 |e resour|ce file |
|00000b40| 6d 75 73 74 20 73 74 69 | 6c 6c 20 62 65 20 70 72 |must sti|ll be pr|
|00000b50| 65 73 65 6e 74 20 65 76 | 65 6e 0d 3b 3b 20 61 66 |esent ev|en.;; af|
|00000b60| 74 65 72 20 61 20 53 41 | 56 45 2d 41 50 50 4c 49 |ter a SA|VE-APPLI|
|00000b70| 43 41 54 49 4f 4e 2e 0d | 3b 3b 0d 28 6c 6f 61 64 |CATION..|;;.(load|
|00000b80| 2d 63 6d 6f 64 75 6c 65 | 20 20 27 65 78 61 6d 70 |-cmodule| 'examp|
|00000b90| 6c 65 29 0d 0d 3b 3b 0d | 3b 3b 20 43 4c 4f 53 45 |le)..;;.|;; CLOSE|
|00000ba0| 2d 43 4d 4f 44 55 4c 45 | 20 63 6c 6f 73 65 73 20 |-CMODULE| closes |
|00000bb0| 74 68 65 20 72 65 73 6f | 75 72 63 65 20 66 69 6c |the reso|urce fil|
|00000bc0| 65 20 61 73 73 6f 63 69 | 61 74 65 64 20 77 69 74 |e associ|ated wit|
|00000bd0| 68 20 79 6f 75 72 20 43 | 20 6d 6f 64 75 6c 65 2e |h your C| module.|
|00000be0| 0d 3b 3b 20 49 74 20 69 | 73 20 76 65 72 79 20 69 |.;; It i|s very i|
|00000bf0| 6d 70 6f 72 74 61 6e 74 | 20 69 66 20 79 6f 75 72 |mportant| if your|
|00000c00| 20 43 20 6d 6f 64 75 6c | 65 20 69 73 20 6d 75 6c | C modul|e is mul|
|00000c10| 74 69 2d 73 65 67 6d 65 | 6e 74 65 64 2c 20 74 68 |ti-segme|nted, th|
|00000c20| 61 74 20 79 6f 75 20 64 | 6f 0d 3b 3b 20 6e 6f 74 |at you d|o.;; not|
|00000c30| 20 63 6c 6f 73 65 20 69 | 74 20 62 65 66 6f 72 65 | close i|t before|
|00000c40| 20 79 6f 75 20 61 72 65 | 20 74 68 72 6f 75 67 68 | you are| through|
|00000c50| 20 75 73 69 6e 67 20 69 | 74 2c 20 61 73 20 61 20 | using i|t, as a |
|00000c60| 63 61 6c 6c 20 74 6f 20 | 61 6e 20 75 6e 6c 6f 61 |call to |an unloa|
|00000c70| 64 65 64 0d 3b 3b 20 73 | 65 67 6d 65 6e 74 20 77 |ded.;; s|egment w|
|00000c80| 69 6c 6c 20 66 6f 72 63 | 65 20 74 68 65 20 73 65 |ill forc|e the se|
|00000c90| 67 6d 65 6e 74 20 6c 6f | 61 64 65 72 20 74 6f 20 |gment lo|ader to |
|00000ca0| 6c 6f 61 64 20 69 74 20 | 66 72 6f 6d 20 79 6f 75 |load it |from you|
|00000cb0| 72 20 72 65 73 6f 75 72 | 63 65 20 66 69 6c 65 2e |r resour|ce file.|
|00000cc0| 0d 3b 3b 0d 28 63 6c 6f | 73 65 2d 63 6d 6f 64 75 |.;;.(clo|se-cmodu|
|00000cd0| 6c 65 20 27 65 78 61 6d | 70 6c 65 29 0d 0d 0d 3b |le 'exam|ple)...;|
|00000ce0| 3b 0d 3b 3b 20 41 20 74 | 79 70 69 63 61 6c 20 64 |;.;; A t|ypical d|
|00000cf0| 65 62 75 67 67 69 6e 67 | 20 63 79 63 6c 65 20 66 |ebugging| cycle f|
|00000d00| 6f 72 20 79 6f 75 72 20 | 43 20 63 6f 64 65 20 77 |or your |C code w|
|00000d10| 69 6c 6c 20 62 65 20 74 | 68 65 20 66 6f 6c 6c 6f |ill be t|he follo|
|00000d20| 77 69 6e 67 3a 0d 3b 3b | 20 59 6f 75 20 65 76 61 |wing:.;;| You eva|
|00000d30| 6c 75 61 74 65 20 79 6f | 75 72 20 44 45 46 43 4d |luate yo|ur DEFCM|
|00000d40| 4f 44 55 4c 45 20 66 6f | 72 6d 20 6f 6e 6c 79 20 |ODULE fo|rm only |
|00000d50| 6f 6e 63 65 2e 0d 3b 3b | 20 41 66 74 65 72 20 74 |once..;;| After t|
|00000d60| 68 61 74 2c 20 79 6f 75 | 20 6c 6f 61 64 20 79 6f |hat, you| load yo|
|00000d70| 75 72 20 43 20 6d 6f 64 | 75 6c 65 20 77 69 74 68 |ur C mod|ule with|
|00000d80| 20 4c 4f 41 44 2d 43 4d | 4f 44 55 4c 45 2c 20 74 | LOAD-CM|ODULE, t|
|00000d90| 65 73 74 20 69 74 2c 0d | 3b 3b 20 63 6c 6f 73 65 |est it,.|;; close|
|00000da0| 20 69 74 20 77 69 74 68 | 20 43 4c 4f 53 45 2d 43 | it with| CLOSE-C|
|00000db0| 4d 4f 44 55 4c 45 2c 20 | 67 6f 20 62 61 63 6b 20 |MODULE, |go back |
|00000dc0| 74 6f 20 54 68 69 6e 6b | 43 2c 20 6d 61 6b 65 20 |to Think|C, make |
|00000dd0| 63 68 61 6e 67 65 73 20 | 74 6f 20 79 6f 75 72 20 |changes |to your |
|00000de0| 63 6f 64 65 2c 0d 3b 3b | 20 72 65 62 75 69 6c 64 |code,.;;| rebuild|
|00000df0| 20 74 68 65 20 63 6f 64 | 65 20 72 65 73 6f 75 72 | the cod|e resour|
|00000e00| 63 65 2c 20 61 6e 64 20 | 74 68 65 20 63 79 63 6c |ce, and |the cycl|
|00000e10| 65 73 20 72 65 70 65 61 | 74 73 20 69 74 73 65 6c |es repea|ts itsel|
|00000e20| 66 2e 0d 3b 3b 0d 0d 0d | 23 7c 0d 28 74 65 73 74 |f..;;...|#|.(test|
|00000e30| 2d 66 69 78 6e 75 6d 20 | 31 30 29 0d 0d 28 74 65 |-fixnum |10)..(te|
|00000e40| 73 74 2d 63 68 61 72 61 | 63 74 65 72 20 23 5c 61 |st-chara|cter #\a|
|00000e50| 29 0d 28 74 65 73 74 2d | 63 68 61 72 61 63 74 65 |).(test-|characte|
|00000e60| 72 20 23 5c 62 29 0d 28 | 74 65 73 74 2d 63 68 61 |r #\b).(|test-cha|
|00000e70| 72 61 63 74 65 72 20 23 | 5c 68 29 0d 0d 28 73 65 |racter #|\h)..(se|
|00000e80| 74 71 20 6c 20 27 28 31 | 20 36 20 37 20 38 20 39 |tq l '(1| 6 7 8 9|
|00000e90| 29 29 0d 28 74 65 73 74 | 2d 6c 69 73 74 20 6c 29 |)).(test|-list l)|
|00000ea0| 0d 6c 0d 0d 28 64 65 66 | 73 74 72 75 63 74 20 66 |.l..(def|struct f|
|00000eb0| 6f 6f 20 61 20 62 20 63 | 29 0d 28 73 65 74 71 20 |oo a b c|).(setq |
|00000ec0| 73 20 28 6d 61 6b 65 2d | 66 6f 6f 20 3a 61 20 31 |s (make-|foo :a 1|
|00000ed0| 30 20 3a 62 20 32 30 20 | 3a 63 20 33 30 29 29 0d |0 :b 20 |:c 30)).|
|00000ee0| 28 74 65 73 74 2d 73 74 | 72 75 63 74 20 73 29 0d |(test-st|ruct s).|
|00000ef0| 73 0d 0d 28 73 65 74 71 | 20 61 20 28 6d 61 6b 65 |s..(setq| a (make|
|00000f00| 2d 61 72 72 61 79 20 35 | 20 3a 69 6e 69 74 69 61 |-array 5| :initia|
|00000f10| 6c 2d 63 6f 6e 74 65 6e | 74 73 20 27 28 31 20 32 |l-conten|ts '(1 2|
|00000f20| 20 33 20 34 20 35 29 29 | 29 0d 28 74 65 73 74 2d | 3 4 5))|).(test-|
|00000f30| 76 65 63 74 6f 72 20 61 | 29 0d 61 0d 0d 28 73 65 |vector a|).a..(se|
|00000f40| 74 71 20 73 20 22 68 65 | 6c 6c 6f 20 68 6f 77 20 |tq s "he|llo how |
|00000f50| 61 72 65 20 79 61 68 22 | 29 0d 28 74 65 73 74 2d |are yah"|).(test-|
|00000f60| 73 74 72 69 6e 67 20 73 | 29 0d 73 0d 0d 28 73 65 |string s|).s..(se|
|00000f70| 74 71 20 61 20 32 2e 33 | 29 0d 28 74 65 73 74 2d |tq a 2.3|).(test-|
|00000f80| 73 68 6f 72 74 2d 64 6f | 75 62 6c 65 20 61 29 0d |short-do|uble a).|
|00000f90| 61 0d 0d 28 73 65 74 71 | 20 61 20 28 25 6d 61 6b |a..(setq| a (%mak|
|00000fa0| 65 2d 64 6f 75 62 6c 65 | 20 32 2e 33 29 29 0d 28 |e-double| 2.3)).(|
|00000fb0| 74 65 73 74 2d 64 6f 75 | 62 6c 65 20 61 29 0d 28 |test-dou|ble a).(|
|00000fc0| 25 67 65 74 2d 64 6f 75 | 62 6c 65 20 61 29 0d 0d |%get-dou|ble a)..|
|00000fd0| 28 64 65 66 72 65 63 6f | 72 64 20 3a 6d 79 72 65 |(defreco|rd :myre|
|00000fe0| 63 6f 72 64 0d 20 20 28 | 61 20 3a 6c 6f 6e 67 29 |cord. (|a :long)|
|00000ff0| 0d 20 20 28 62 20 3a 6c | 6f 6e 67 29 0d 20 20 28 |. (b :l|ong). (|
|00001000| 63 20 3a 6c 6f 6e 67 29 | 29 0d 28 73 65 74 71 20 |c :long)|).(setq |
|00001010| 61 20 28 6d 61 6b 65 2d | 72 65 63 6f 72 64 20 3a |a (make-|record :|
|00001020| 6d 79 72 65 63 6f 72 64 | 20 3a 61 20 33 20 3a 62 |myrecord| :a 3 :b|
|00001030| 20 34 20 3a 63 20 38 29 | 29 0d 28 74 65 73 74 2d | 4 :c 8)|).(test-|
|00001040| 63 2d 73 74 72 75 63 74 | 75 72 65 73 20 61 29 0d |c-struct|ures a).|
|00001050| 28 70 72 69 6e 74 2d 72 | 65 63 6f 72 64 20 61 20 |(print-r|ecord a |
|00001060| 3a 6d 79 72 65 63 6f 72 | 64 29 0d 0d 28 73 65 74 |:myrecor|d)..(set|
|00001070| 71 20 70 20 28 23 5f 6e | 65 77 50 74 72 20 31 30 |q p (#_n|ewPtr 10|
|00001080| 29 29 0d 28 74 65 73 74 | 2d 61 30 20 70 29 0d 0d |)).(test|-a0 p)..|
|00001090| 3b 3b 0d 3b 3b 20 44 6f | 6e 74 20 77 6f 72 72 79 |;;.;; Do|nt worry|
|000010a0| 20 61 62 6f 75 74 20 74 | 68 65 20 77 61 72 6e 69 | about t|he warni|
|000010b0| 6e 67 0d 3b 3b 20 69 74 | 20 73 68 6f 75 6c 64 20 |ng.;; it| should |
|000010c0| 6e 6f 74 20 62 65 20 74 | 68 65 72 65 20 69 6e 20 |not be t|here in |
|000010d0| 4d 43 4c 32 2e 30 20 66 | 69 6e 61 6c 21 0d 3b 3b |MCL2.0 f|inal!.;;|
|000010e0| 0d 28 64 65 66 63 63 61 | 6c 6c 61 62 6c 65 20 67 |.(defcca|llable g|
|000010f0| 63 20 28 28 3a 72 65 73 | 75 6c 74 20 3a 76 6f 69 |c ((:res|ult :voi|
|00001100| 64 29 29 20 28 67 63 29 | 29 0d 28 74 65 73 74 2d |d)) (gc)|).(test-|
|00001110| 63 61 6c 6c 62 61 63 6b | 20 27 28 32 20 33 20 34 |callback| '(2 3 4|
|00001120| 29 20 67 63 29 0d 0d 28 | 74 65 73 74 2d 67 6c 6f |) gc)..(|test-glo|
|00001130| 62 61 6c 73 29 0d 0d 3b | 3b 0d 3b 3b 20 49 66 20 |bals)..;|;.;; If |
|00001140| 79 6f 75 20 69 6e 61 64 | 76 65 72 74 65 6e 74 6c |you inad|vertentl|
|00001150| 79 20 65 76 61 6c 75 61 | 74 65 64 20 74 68 65 20 |y evalua|ted the |
|00001160| 43 4c 4f 53 45 2d 43 4d | 4f 44 55 4c 45 20 66 6f |CLOSE-CM|ODULE fo|
|00001170| 72 6d 0d 3b 3b 20 69 6e | 20 74 68 65 20 6d 69 64 |rm.;; in| the mid|
|00001180| 64 6c 65 20 6f 66 20 74 | 68 69 73 20 66 69 6c 65 |dle of t|his file|
|00001190| 2c 20 69 74 20 69 73 20 | 6e 6f 74 20 74 6f 20 6c |, it is |not to l|
|000011a0| 61 74 65 20 74 6f 20 72 | 65 6c 6f 61 64 20 79 6f |ate to r|eload yo|
|000011b0| 75 72 0d 3b 3b 20 6d 6f | 64 75 6c 65 20 77 69 74 |ur.;; mo|dule wit|
|000011c0| 68 20 74 68 65 20 4c 4f | 41 44 2d 43 4d 4f 44 55 |h the LO|AD-CMODU|
|000011d0| 4c 45 20 66 6f 72 6d 2c | 20 62 65 66 6f 72 65 20 |LE form,| before |
|000011e0| 69 74 20 63 72 61 73 68 | 65 73 20 77 69 74 68 20 |it crash|es with |
|000011f0| 61 6e 0d 3b 3b 20 65 72 | 72 6f 72 20 6f 66 20 74 |an.;; er|ror of t|
|00001200| 79 70 65 20 31 35 21 0d | 3b 3b 0d 28 74 65 73 74 |ype 15!.|;;.(test|
|00001210| 2d 6d 75 6c 74 69 2d 73 | 65 67 6d 65 6e 74 29 0d |-multi-s|egment).|
|00001220| 0d 28 74 65 73 74 2d 74 | 72 61 70 73 29 0d 0d 28 |.(test-t|raps)..(|
|00001230| 25 67 65 74 2d 6c 6f 6e | 67 20 6d 79 2d 6c 6f 6e |%get-lon|g my-lon|
|00001240| 67 29 0d 28 25 67 65 74 | 2d 64 6f 75 62 6c 65 20 |g).(%get|-double |
|00001250| 6d 79 2d 64 6f 75 62 6c | 65 29 0d 0d 28 73 65 74 |my-doubl|e)..(set|
|00001260| 66 20 28 25 67 65 74 2d | 6c 6f 6e 67 20 6d 79 2d |f (%get-|long my-|
|00001270| 6c 6f 6e 67 29 20 37 29 | 0d 28 74 65 73 74 2d 67 |long) 7)|.(test-g|
|00001280| 6c 6f 62 61 6c 73 29 0d | 7c 23 0d 00 00 00 00 00 |lobals).||#......|
|00001290| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|000012a0| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|000012b0| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|000012c0| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|000012d0| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|000012e0| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|000012f0| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|00001300| 00 00 01 00 00 00 01 76 | 00 00 00 76 00 00 00 46 |.......v|...v...F|
|00001310| 6f 73 73 69 62 6c 65 20 | 64 27 6f 75 76 72 69 72 |ossible |d'ouvrir|
|00001320| 20 6f 75 20 64 27 69 6d | 70 72 69 6d 65 72 20 64 | ou d'im|primer d|
|00001330| 0c 65 78 61 6d 70 6c 65 | 2e 6c 69 73 70 cd 02 00 |.example|.lisp...|
|00001340| 00 00 54 45 58 54 43 43 | 4c 32 01 00 00 03 00 64 |..TEXTCC|L2.....d|
|00001350| 00 00 54 45 58 54 43 43 | 4c 32 01 00 00 03 00 64 |..TEXTCC|L2.....d|
|00001360| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|00001370| 00 00 a3 c1 9f f0 00 00 | 12 0b 00 00 01 bc 72 20 |........|......r |
|00001380| 6c 27 61 70 70 6c 69 63 | 61 74 69 6f 6e 20 d2 5e |l'applic|ation .^|
|00001390| 31 d3 20 28 5e 30 29 2e | 20 51 75 69 74 74 65 7a |1. (^0).| Quittez|
|000013a0| 20 75 6e 65 20 61 75 74 | 72 65 20 61 70 70 6c 69 | une aut|re appli|
|000013b0| 63 61 74 69 6f 6e 20 70 | 6f 75 72 20 72 8e 63 75 |cation p|our r.cu|
|000013c0| 70 8e 72 65 72 20 64 65 | 20 6c 27 65 73 70 61 63 |p.rer de| l'espac|
|000013d0| 65 20 6d 8e 6d 6f 69 72 | 65 2e 1b 5e 30 20 72 65 |e m.moir|e..^0 re|
|000013e0| 71 75 69 73 2c 20 5e 30 | 20 64 69 73 70 6f 6e 69 |quis, ^0| disponi|
|000013f0| 62 6c 65 28 73 29 28 49 | 6d 70 6f 73 73 69 62 6c |ble(s)(I|mpossibl|
|00001400| 00 00 00 48 00 09 4d 6f | 6e 61 63 6f 00 bb 01 00 |...H..Mo|naco....|
|00001410| 00 c0 6d 61 00 00 00 28 | 00 27 f9 cc 00 02 00 04 |..ma...(|.'......|
|00001420| 09 00 00 04 09 01 00 06 | 00 08 00 2b 00 05 01 da |........|...+....|
|00001430| 02 23 00 2b 00 05 01 da | 02 23 00 28 00 00 00 00 |.#.+....|.#.(....|
|00001440| 00 85 00 00 00 85 00 00 | 00 00 01 00 00 00 00 26 |........|.......&|
|00001450| 00 02 00 04 09 00 00 04 | 09 01 01 00 00 00 02 00 |........|........|
|00001460| 00 26 01 00 00 4e 02 00 | 00 8e 01 00 00 9d 02 00 |.&...N..|........|
|00001470| 00 b3 01 00 00 ba 00 00 | 01 00 00 00 01 76 00 00 |........|.....v..|
|00001480| 00 76 00 00 00 46 00 8a | df f0 0b c2 00 00 00 1c |.v...F..|........|
|00001490| 00 46 00 01 4d 50 53 52 | 00 00 00 12 46 52 45 44 |.F..MPSR|....FRED|
|000014a0| 00 00 00 1e 03 ed ff ff | 00 00 00 00 00 8a df f8 |........|........|
|000014b0| 00 02 ff ff 00 00 00 4c | 00 00 00 00 00 00 00 00 |.......L|........|
|000014c0| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|000014d0| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|000014e0| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|000014f0| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
+--------+-------------------------+-------------------------+--------+--------+